<?PHP
require_once("../settings.php");
require_once("../connect.php");
require_once("../functions.php");

foreach ($settings['divisions'] as $division) {
$data['accountKey'] = $division;

# Run Corp Journal XML and insert into database
	if ($settings['corpjournal'] == true) {
$url = "http://api.eve-online.com/corp/WalletJournal.xml.aspx";
get_api($url);
	$xml = simplexml_load_file($xmlfile);
	unlink($xmlfile);
	if ($xml->error) {
		echo $xml->error[code].'<br />';
		log_error(array($info,$xml->error));
	}
	else {
		foreach ($xml->result->rowset->row as $row) {
		$query7 = "
INSERT IGNORE INTO `jcorp` (`date`,`refID`,`refTypeID`,`ownerName1`,`ownerID1`,`ownerName2`,`ownerID2`,`argName1`,`argID1`,`amount`,`balance`,`reason`,`division`) VALUES ('".mysql_real_escape_string($row[date])."','".mysql_real_escape_string($row[refID])."','".mysql_real_escape_string($row[refTypeID])."','".mysql_real_escape_string($row[ownerName1])."','".mysql_real_escape_string($row[ownerID1])."','".mysql_real_escape_string($row[ownerName2])."','".mysql_real_escape_string($row[ownerID2])."','".mysql_real_escape_string($row[argName1])."','".mysql_real_escape_string($row[argID1])."','".mysql_real_escape_string($row[amount])."','".mysql_real_escape_string($row[balance])."','".mysql_real_escape_string($row[reason])."','".mysql_real_escape_string($division)."')";
		$result = $db->query($query7);
		}
	}
	} # End Corp Journal XML

}

?>